// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import './prototype'
import myDebugger from './debugger'
import 'jquery/dist/jquery.min.js'
// import 'bootstrap/dist/css/bootstrap.min.css'
// import 'bootstrap/dist/js/bootstrap.min.js'
import $ from 'jquery'
import Vue from 'vue'
import 'vue-awesome/icons/home'
import 'vue-awesome/icons/search'
import 'vue-awesome/icons/bars'
import 'vue-awesome/icons/envelope'
import 'vue-awesome/icons/tasks'
import Icon from 'vue-awesome/components/Icon'
Vue.component('icon', Icon)
import axios from './api/ajax'
import router from './router'
import store from './store'
import api from './api'

import App from './App'

import config from './config'
import constant from './constant'

import cookie from './core/cookie'
import uploadImageOption from './core/upload-image'
// element-ui组件样式
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
Vue.use(ElementUI)
import * as filters from './filters'
Vue.config.productionTip = false

// 注册全局过滤器
Object.keys(filters).forEach(k => Vue.filter(k, filters[k]))
window.$ = $
window.$messageBox = ElementUI.MessageBox
window.$loading = ElementUI.Loading
window.$alert = ElementUI.MessageBox.alert
window.$confirm = ElementUI.MessageBox.confirm
window.$prompt = ElementUI.MessageBox.prompt
window.$notify = ElementUI.Notification
window.$message = ElementUI.Message
window.hideAside = function () {
  let winW = $(window).width()
  let $appElement = $('#app')

  // 如果不是中等屏幕以上（桌面显示器）
  if (winW < 992) {
    $appElement.addClass('hide-left-aside')
  }
}

// 添加Vue的原型链(只读)
Object.defineProperty(Vue.prototype, '$axios', { value: axios })
Object.defineProperty(Vue.prototype, 'Config', { value: config })
Object.defineProperty(Vue.prototype, 'Constant', { value: constant })
Object.defineProperty(Vue.prototype, 'MyDebugger', { value: myDebugger })
Object.defineProperty(Vue.prototype, '$cookie', { value: cookie })
Object.defineProperty(Vue.prototype, '$uploadImage', { value: uploadImageOption })
Object.defineProperty(Vue.prototype, 'Api', { value: api })
Object.defineProperty(Vue.prototype, '$filters', { value: filters })
/**
 * 可修改
 */
/* Vue.prototype.$config = config */
Vue.prototype.$store = store
// element-ui组件
Vue.prototype.$loading = ElementUI.Loading
Vue.prototype.$MessageBox = ElementUI.MessageBox
Vue.prototype.$alert = ElementUI.MessageBox.alert
Vue.prototype.$confirm = ElementUI.MessageBox.confirm
Vue.prototype.$prompt = ElementUI.MessageBox.prompt
Vue.prototype.$notify = ElementUI.Notification
Vue.prototype.$message = ElementUI.Message
/* eslint-disable */
// 注册全局异常捕获器
Vue.config.errorHandler = function(err, vm, info) {
    myDebugger.log(arguments)
}

/* eslint-disable no-new */
new Vue({
    el: document.getElementById('app'),
    router,
    store,
    template: '<App/>',
    components: { App }
})
